package cn.calm.xhtml.listener;

import org.eclipse.core.resources.IProject;
import static cn.calm.xhtml.XhtmlActivator.logInfo;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;

public class ResourceDeltaVisitor implements IResourceDeltaVisitor{
	@Override
	public boolean visit(IResourceDelta delta) throws CoreException {
		if (delta.getKind() != IResourceDelta.CHANGED) {
			return true;
		}
		final IResource resource = delta.getResource();
		switch (delta.getFlags()) {
		case IResourceDelta.OPEN:
			if (!(resource instanceof IProject)) {
				return true;
			}
			logInfo(resource+"");
			break;
		case IResourceDelta.ADDED:
			if (!(resource instanceof IProject)) {
				return true;
			}
			logInfo(resource+"");
			break;
		default:
			break;
		}
		return true;
	}
}
